<?PHP
	class UrlRewriting_Installer{
	
		public static function GetUrlByAlias($alias,$parameter = ""){
			return self::getCurrentFolderUrl().GetShortUrlByAlias($alias,$parameter);
		}
	
		public static function GetShortUrlByAlias($alias,$parameter = ""){
			$res = $alias.".html";
			if(!self::hasModRewrite()){
				$res = "index.php?include=".$alias;
			}
			if($parameter != ""){
				$res .= self::GetFirstParameterSeperator().$parameter;
			}
			return $res;
		}
	
		public static function hasModRewrite(){
			return !(getenv('HTTP_MOD_REWRITE')=='Off' || (function_exists("apache_get_modules") && !in_array("mod_rewrite",@apache_get_modules())));
		}
		
		public static function GetFirstParameterSeperator(){
			$res = "?";
			if(!self::hasModRewrite()){
				$res = "&";
			}
			return $res;
		}

		private static function getCurrentFolderUrl(){
		  if($_SESSION['installer']->isHttps()){
			$res = "https://";
		  }
		  else{
			$res = "http://";
		  }
		  $res .= $_SERVER['HTTP_HOST'];
		  $parts = explode("/",$_SERVER['REQUEST_URI']);
		  for($i = 0;$i < count($parts) -1;$i++){
			$res .= $parts[$i]."/";
		  }
		  return $res;
		}
	
	}
?>